<template>
  <basic-container>
    <avue-crud
      :option="option"
      :table-loading="loading"
      :data="data"
      ref="crud"
      :page="page"
      v-model="form"
      @current-change="currentChange"
      @size-change="sizeChange"
      @on-load="onLoad"
    >
      <template slot-scope="{ type, size, row }" slot="menu">
        <el-button
          v-if="row.status != 2"
          icon="el-icon-check"
          :size="size"
          :type="type"
          @click="createReport(row)"
          >生成报告</el-button
        >
        <span v-else>已生成报告</span>
      </template>
    </avue-crud>
    <el-dialog title="生成报告" :visible.sync="dialogFormVisible" width="30%">
      <span>这是一段信息</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogFormVisible = false"
          >确 定</el-button
        >
      </span>
    </el-dialog>
  </basic-container>
</template>

<script>
import { getStore } from "@/util/store";
import { getList } from "@/api/consulting/order.js";

export default {
  data() {
    return {
      imageUrl: "",
      loading: true,
      form: {},
      dialogFormVisible: false,
      articleFullscreen: false,
      query: {},
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
      option: {
        border: true,
        align: "left",
        menuAlign: "center",
        addBtn: false,
        columnBtn: false,
        refreshBtn: false,
        editBtn: false,
        delBtn: false,
        column: [
          {
            label: "预约人",
            prop: "userName",
          },
          {
            label: "预约编号",
            prop: "appointmentReceiveCode",
          },
          {
            label: "开始时间",
            prop: "startTime",
          },
          {
            label: "结束时间",
            prop: "endTime",
          },
        ],
      },
      data: [],
      row: {},
    };
  },
  watch: {},
  created() {},
  mounted() {},
  methods: {
    currentChange(currentPage) {
      //分页页码
      this.page.currentPage = currentPage;
    },
    sizeChange(pageSize) {
      //分页条数
      this.page.pageSize = pageSize;
    },
    async onLoad(page) {
      this.loading = true;
      await getList(page.currentPage, page.pageSize).then((res) => {
        this.data = res.data.data.records;
        this.loading = false;
        this.page.pageSize = res.data.data.size;
        this.page.currentPage = res.data.data.current;
        this.page.total = res.data.data.total;
      });
    },
    createReport(row) {
      this.dialogFormVisible = true;
      this.row = row;
    },
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then(() => {
          done();
        })
        .catch(() => {});
    },
  },
};
</script>

<style scoped lang="scss">
.preview {
  min-height: 150px;
}

::v-deep.el-dialog__header {
  padding: 16px 24px;
  min-height: 20px;
  border-bottom: 1px solid #f0f0f0;
}

.articleForm .el-select,
.articleForm .el-input {
  width: 360px;
}

.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}
.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
</style>
